<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2024/9/18
  Time: 上午10:30
  Description: 查看借用申请详情
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>查看借用申请详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <!-- 设备编号 -->
    <div class="layui-form-item">
        <label class="layui-form-label">设备编号</label>
        <div class="layui-input-block">
            <input type="text" id="equipment_id" name="equipment_id" class="layui-input" readonly>
        </div>
    </div>

    <!-- 起始时间 -->
    <div class="layui-form-item">
        <label class="layui-form-label">起始时间</label>
        <div class="layui-input-block">
            <input type="text" id="start_date" name="start_date" class="layui-input" readonly>
        </div>
    </div>

    <!-- 借用天数 -->
    <div class="layui-form-item">
        <label class="layui-form-label">借用天数</label>
        <div class="layui-input-block">
            <input type="text" id="expected_days" name="expected_days" class="layui-input" readonly>
        </div>
    </div>

    <!-- 申请状态 -->
    <div class="layui-form-item">
        <label class="layui-form-label">申请状态</label>
        <div class="layui-input-block">
            <input type="text" id="approval_status" name="approval_status" class="layui-input" readonly>
        </div>
    </div>

    <!-- 备注信息 -->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea id="remarks" name="remarks" class="layui-textarea" readonly></textarea>
        </div>
    </div>
</div>

<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['jquery'], function () {
        var $ = layui.jquery;

        var equipment_id = new URLSearchParams(window.location.search).get('equipment_id');

        if (equipment_id) {
            $.ajax({
                url: '${pageContext.request.contextPath}/borrowServlet',
                type: 'GET',
                data: { method: 'getBorrowApplicationById', equipment_id: equipment_id},
                success: function (response) {
                    var data = JSON.parse(response);
                    if (data.code === 0) {
                        var application = data.data;
                        // 填充表单
                        $('#equipment_id').val(application.equipment_id);
                        $('#start_date').val(application.start_date);
                        $('#expected_days').val(application.expected_days);
                        $('#approval_status').val(application.approval_status);
                        $('#remarks').val(application.remarks);
                    } else {
                        alert("借用申请详情获取失败");
                    }
                },
                error: function () {
                    alert("请求失败");
                }
            });
        } else {
            alert("未获取到申请ID");
        }
    });
</script>
</body>
</html>
